package org.wwx.register;

import org.wwx.common.URL;

import java.util.Collections;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.CopyOnWriteArrayList;

/**
 * @date 2025/6/6
 * @author王闻薪
 */
public class MapRemoteRegister {
    private static final ConcurrentMap<String, List<URL>> map = new ConcurrentHashMap<>();

    public static void register(String className, URL url) {
        map.compute(className, (k, v) -> {
            if (v == null) {
                v = new CopyOnWriteArrayList<>();
            }
            v.add(url);
            return v;
        });
    }

    public static List<URL> get(String className) {
        return map.getOrDefault(className, Collections.emptyList());
    }
}
